package com.gitxinghui;

import cn.hutool.core.util.ReUtil;
import cn.hutool.http.HttpUtil;
import com.gitxinghui.constants.GitHubUrl;

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {

        System.out.println("Hello world!");

        //TODO: 1、先模拟网络访问，获取ip地址
//        String url = GitHubUrl.SELECT_IP_ADDRESS_URL + "alive.github.com";
//        String content = HttpUtil.get(url);
//        System.out.println(content);
//
//        //TODO: 2、正则解析，打印ip地址
//        ArrayList<String> all = ReUtil.findAll(GitHubUrl.IP_PATTERN, content, 0, new ArrayList<String>());
//        System.out.println(all.get(0));


        //TOTO: 3、优化，批量处理多个域名地址，封装为方法，用多线程解决速度问题。

        GetIpThree getIpThree = new GetIpThree();

        Thread thread1 = new Thread(getIpThree);
        Thread thread2 = new Thread(getIpThree);
        Thread thread3 = new Thread(getIpThree);

        thread1.start();
        thread2.start();
        thread3.start();



//        GetIpThree getIpThree2 = new GetIpThree();
//        GetIpThree getIpThree3 = new GetIpThree();
//        GetIpThree getIpThree4 = new GetIpThree();
//        GetIpThree getIpThree5 = new GetIpThree();



//        PrintNumberRunnable2 runnable = new PrintNumberRunnable2();
//        Thread t1 = new Thread(runnable);
//        Thread t2 = new Thread(runnable);
//        t1.start();
//        t2.start();

    }



}